Skip to content

feat: JVM init goal, int-backed enum arrays, full view expressions - #626

Merged
dmealing merged 8 commits into
mainfrom
fm/mo-130-lane-jvm-bundle2
Nov 21, 2026
Merged

dmealing merged 8 commits into
mainfrom
fm/mo-130-lane-jvm-bundle2

Conversation

@dmealing

@dmealing dmealing commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • Maven plugin metaobjects:init goal. Writes .metaobjects/config.json and an empty, loadable metaobjects/meta.app.json, each only when missing. Prints the <plugin> entry to add to the pom with an empty <generators/>; it never edits pom.xml. -Dmeta.init.withDocs=true adds the api reference generator to that printed entry.
  • Int-backed field.enum arrays persist as their declared integers. OMDB writes a native integer[] on Postgres and a JSON array of numbers ([5,0]) on SQLite, MySQL and Derby, where it used to refuse the field. The Kotlin Exposed generator emits a portableIntEnumArray column plus a MetaIntEnumArrayColumnType.kt support file, replacing a scalar column that did not compile. String-backed enum arrays are unchanged and still lack an Exposed array column.
  • Java loader accepts the full view expression set. ExpressionAttribute and ValidationPhase now check every view function and cast the way the TypeScript port does, and quoted number-like text (for example "007") stays a string instead of being read as a number. The layout ratchet test helper also fails on unparsable files, and two writer helpers in codegen-base are now protected.
Validation

Risk Assessment

✅ Low: The change is bounded and consistent with the lane intent (JVM loader parity, OMDB/Exposed int-backed enum arrays, init goal). I traced the code paths and found no wrong-result defects; the conformance ledgers are emptied only where the new code covers the fixtures. Remaining items are minor doc, duplication and test-oracle nits.

Testing

Drove the Java and Kotlin lane changes against the real product code in-process: D7 Maven init goal across four disposable project shapes, C1 and C4 Java loader on corpus fixtures plus adversarial YAML, and C6 Kotlin int-enum-array generation plus a successful compile of the emitted tree. All three driven scenarios pass with live transcripts. The OMDB int-array persistence half of C6 was not driven live (needs a Postgres roundtrip) and is reported untested. The configured affected-lane command passed at this commit and was not re-run. Verdict go on the driven scope.

  • Live validation: ✅ go - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
D7: Maven plugin metaobjects:init scaffolds a fresh project, keeps existing files, never edits pom.xml, and prints the pom entry (docs opt-in honored) ✅ pass live evidence/c-d7-maven-init-goal-transcript.txt
C1: Java loader accepts view-expression vocabulary (casts, functions) and still refuses an invalid cast with ERR_INVALID_ORIGIN ✅ pass live evidence/c1-c4-java-loader-transcript.txt
C4: Java loader keeps quoted number-like text a string ("007", "true") and refuses an unquoted number on a string attribute instead of coercing ✅ pass live evidence/c1-c4-java-loader-transcript.txt
C6a: Kotlin Exposed generator emits an int-backed enum array as an integer array column with support file, and the emitted tree compiles ✅ pass live evidence/c6-kotlin-int-enum-array (acme/shop/DocTable.kt, MetaIntEnumArrayColumnType.kt; kotlinc-compile.log)
C6b: OMDB persists an int-backed enum array as declared integers (native integer[] on Postgres, JSON number array elsewhere) and refuses a member with no declared integer ⏸️ untested no Tried: reading the Java persistence path and existing focused tests (not live). Not driven live here because it needs a disposable Postgres (docker is present at /usr/bin/docker, Testcontainers Postgr…
Evidence: D7 maven init goal transcript (live InitMojo runs)
\### RUN 1: empty project p1
[info] wrote .metaobjects/config.json
[info] wrote metaobjects/meta.app.json
[info] Add this to the <build><plugins> of your pom.xml (init never edits it):
    <plugin>
      <groupId>com.metaobjects</groupId>
      <artifactId>metaobjects-maven-plugin</artifactId>
      <version>${metaobjects.version}</version>
      <configuration>
        <generators/>
      </configuration>
    </plugin>
[info] next: describe your entities in metaobjects/, list the generators you want, then run `mvn metaobjects:generate`.
INIT_OK true
\### RUN 2: rerun p1 (must keep both)
[info] kept .metaobjects/config.json (already exists)
[info] kept metaobjects/meta.app.json (already exists)
[info] Add this to the <build><plugins> of your pom.xml (init never edits it):
    <plugin>
      <groupId>com.metaobjects</groupId>
      <artifactId>metaobjects-maven-plugin</artifactId>
      <version>${metaobjects.version}</version>
      <configuration>
        <generators/>
      </configuration>
    </plugin>
[info] next: describe your entities in metaobjects/, list the generators you want, then run `mvn metaobjects:generate`.
INIT_OK true
\### RUN 3: p2 has custom config (must keep it, write meta.app.json)
[info] wrote metaobjects/meta.app.json
[info] kept .metaobjects/config.json (already exists)
[info] Add this to the <build><plugins> of your pom.xml (init never edits it):
    <plugin>
      <groupId>com.metaobjects</groupId>
      <artifactId>metaobjects-maven-plugin</artifactId>
      <version>${metaobjects.version}</version>
      <configuration>
        <generators/>
      </configuration>
    </plugin>
[info] next: describe your entities in metaobjects/, list the generators you want, then run `mvn metaobjects:generate`.
INIT_OK true
\### RUN 4: p4 has pom.xml, docs opt-in
[info] wrote .metaobjects/config.json
[info] wrote metaobjects/meta.app.json
[info] Add this to the <build><plugins> of your pom.xml (init never edits it):
    <plugin>
      <groupId>com.metaobjects</groupId>
      <artifactId>metaobjects-maven-plugin</artifactId>
      <version>${metaobjects.version}</version>
      <configuration>
        <generators>
          <generator>
            <classname>com.metaobjects.generator.apidocs.JavaApiDocsGenerator</classname>
            <args>
              <outputDir>docs</outputDir>
            </args>
          </generator>
        </generators>
      </configuration>
    </plugin>
[info] next: describe your entities in metaobjects/, list the generators you want, then run `mvn metaobjects:generate`.
INIT_OK true
Evidence: C1/C4 Java loader transcript (live loader on fixtures and adversarial YAML)
\### C1 positive: view-expression fixture loads, canonical == expected.json
LOADED projection-view-vocabulary-rc21
CANONICAL_MATCH_EXPECTED projection-view-vocabulary-rc21
\### C1 negative: cast of non-int-stored enum must be refused
CAUSE MetaDataException: ERR_INVALID_ORIGIN: origin.computed on acme::views::V.k: 'cast': only an enum stored as an integer (@intValueMap) can be cast to a number
\### C4 positive: quoted "007" stays string, canonical == expected.json
LOADED yaml-quoted-leading-zero
CANONICAL_MATCH_EXPECTED yaml-quoted-leading-zero
\### C4 adversarial: quoted "007" and "true" stay strings
LOADED q-quoted
CANON { "metadata.root": { "children": [ { "object.entity": { "name": "Product", "children": [ { "field.string": { "name": "code", "@column": "007" } }, { "field.string": { "name": "flag", "@column": "true" } }, { "field.string": { "name": "string" } } ] } } ] } } 
\### C4 adversarial: unquoted 7 on string attr is refused (no silent coercion)
CAUSE MetaDataException: Attribute '@column' at <root>.children[0].children[0]: expected string but got number (7). YAML 1.2 silently coerced an unquoted value — quote it in YAML: '@column: "7"' not '@column: 7'. (file [meta.neg.yaml])
  • Evidence: C6 Kotlin generated int-enum-array output and kotlinc compile log (exit 0) (local run artifact, not committed)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 4 infos
  • ℹ️ server/java/codegen-kotlin/src/main/kotlin/com/metaobjects/generator/kotlin/KotlinExposedTableGenerator.kt:335 - Pass comments were misordered by the new loop. The new int-enum-array support-file loop was inserted directly under the existing '// Pass 3f: ONE shared MetaDurationColumnType.kt ...' comment, so that comment described the wrong loop. Fixed inline: the new loop now has its own '// Pass 3g' comment and the 3f comment sits above the duration loop. Comment-only change.
  • ℹ️ docs/features/field-types.md:252 - The parenthetical '(Python on SQLite and MySQL is the one place that still does.)' reads as if Python writes member symbols there. docs/ports/python.md says those engines store no enum array of either kind (Postgres-only). Reword to say that, or drop the parenthetical. Not edited inline because the sentence wraps across lines in the file.
  • ℹ️ server/java/metadata/src/main/java/com/metaobjects/loader/ValidationPhase.java:503 - originStringList (MetaOrigin) duplicates ownStringList (MetaData) line for line. MetaOrigin is a MetaData, so one helper serves both; the origin one can delegate or be deleted.
  • ℹ️ server/java/maven-plugin/src/test/java/com/metaobjects/mojo/InitMojoTest.java:25 - The comment, CHANGELOG and docs say the scaffold config is identical to what every other port's init writes. InitMojoTest checks only the Java constant's own substrings, so a drift from the TS/C# init output would pass. The C# init builds the same JSON from shared constants. A test that compares against a cross-port expected value, or a shared fixture, would be an independent oracle.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
D7: Maven plugin metaobjects:init scaffolds a fresh project, keeps existing files, never edits pom.xml, and prints the pom entry (docs opt-in honored) ✅ pass live evidence/c-d7-maven-init-goal-transcript.txt
C1: Java loader accepts view-expression vocabulary (casts, functions) and still refuses an invalid cast with ERR_INVALID_ORIGIN ✅ pass live evidence/c1-c4-java-loader-transcript.txt
C4: Java loader keeps quoted number-like text a string ("007", "true") and refuses an unquoted number on a string attribute instead of coercing ✅ pass live evidence/c1-c4-java-loader-transcript.txt
C6a: Kotlin Exposed generator emits an int-backed enum array as an integer array column with support file, and the emitted tree compiles ✅ pass live evidence/c6-kotlin-int-enum-array (acme/shop/DocTable.kt, MetaIntEnumArrayColumnType.kt; kotlinc-compile.log)
C6b: OMDB persists an int-backed enum array as declared integers (native integer[] on Postgres, JSON number array elsewhere) and refuses a member with no declared integer ⏸️ untested no Tried: reading the Java persistence path and existing focused tests (not live). Not driven live here because it needs a disposable Postgres (docker is present at /usr/bin/docker, Testcontainers Postgr…
  • scripts/ci-local.sh --affected --strict-toolchains
  • Baseline (given): scripts/ci-local.sh --affected --strict-toolchains passed at 168ff8dc77; broad regression came from that configured test command with its passing outcome. No source or test files changed in this turn, so the command was not re-run.
  • Offline dependency classpaths: mvn -o -q -f server/java/&lt;module&gt;/pom.xml dependency:build-classpath for metadata, maven-plugin, codegen-kotlin (outputs in scratch).
  • Maven init goal driven live: javac-compiled driver calling InitMojo.execute() with baseDir/withDocs set, run in 4 disposable project dirs (fresh, rerun, existing config, pom present + docs opt-in); sha256 check of kept files; Java loader load of the scaffolded metaobjects/ dir.
  • Java loader driver (MetaDataLoader.fromDirectory, CanonicalJsonSerializer) on fixtures/conformance/projection-view-vocabulary-rc21, error-computed-cast-enum-not-int-stored, fixtures/yaml-conformance/yaml-quoted-leading-zero, and inline quoted/unquoted YAML adversarial inputs.
  • Kotlin generators (KotlinEntityGenerator, KotlinExposedTableGenerator) run via Java driver on codegen-kotlin test model enum-int-backed-array against reactor target/classes; generated tree compiled with kotlin-compiler 2.0.21 K2JVMCompiler, Exposed 0.55.0 and kotlinx-serialization-core 1.7.3 on the classpath.
  • Scratch under DEV_SCRATCH removed; worktree git status clean.
⚠️ **Document** - 6 issues (1 error, 3 warnings, 2 infos)
  • 🚨 docs/features/field-types.md:250 - docs/features/field-types.md said Python on SQLite and MySQL writes member symbols for int-backed enum arrays. Python's codec encodes ints element-wise on every dialect and has no SQLite/MySQL array path, so the claim was wrong. Reworded to point at the port page without asserting a refusal.
  • ⚠️ docs/CONFORMANCE.md:96 - docs/CONFORMANCE.md said there were two ledgered YAML fixtures and pointed at a _comment in each port's ledger. Java's YAML ledger is now empty and its note is gone. Reworded to cover the C# and Rust ledgers.
  • ⚠️ docs/features/cli.md:42 - docs/features/cli.md repeated the init settings list that docs/ports/java.md owns. Reduced the cli.md row to a short pointer to the Java port page.
  • ⚠️ server/java/maven-plugin/src/main/java/com/metaobjects/mojo/InitMojo.java:34 - InitMojo Javadoc cited mvn metaobjects:generate --list, which does not exist (no list parameter on the goal). Pointed it at the generator catalog in docs/ports/java.md.
  • ℹ️ Out-of-scope consolidation: the int-backed enum-array per-port behavior is restated in .claude/rules/cross-language-porting.md, docs/features/field-types.md, docs/ports/{java,kotlin,python,csharp}.md, the CHANGELOG 1.3.0 entries and two KNOWN_GAPS/Javadoc sites. Follow-up: make the rules file and field-types.md the single owners and reduce the port pages to pointers.
  • ℹ️ Unverified: what Python's runtime does with an int-backed enum array on SQLite/MySQL. The codec passes a Python list to the driver and no array path exists. Docs now say only that it is Postgres-only. Settling it needs a live SQLite/MySQL run, which I did not do.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…e files in the layout ratchet

CodeWriter.describe and JavaWriter.simpleName follow the spec rule that writer methods are public or protected, never private. The layout analyzer now throws when javac reports a syntax error, so a generator file that does not parse is never counted as clean.
Ports the rc.21 view vocabulary to the JVM loader (and so Kotlin): the typed function set beside coalesce, cast with dbColumnType spellings, int-stored enum casts, origin.function validation, union and grain checks, and path operands in correlated filters. The five conformance fixtures the Java ledger excused now pass and the ledger is empty.
A quoted value on a string attribute (column: "007") was inferred as the integer 7. Quoted text is now never inferred, matching every other port, and the YAML conformance ledger is empty. Also records the C1 and C6 fixes in the changelog.
An int-backed field.enum array stores each member as its declared integer: a native integer[] on Postgres, a JSON array of numbers in a text column on SQLite, MySQL and Derby. A member with no declared integer is refused on write and a stored integer with no member fails the read. The shared roundtrip-int-enum-array scenario now runs on Postgres, SQLite and MySQL in the Java lane, so its deferral is gone.
…m arrays

An isArray field.enum with an @intValueMap now gets portableIntEnumArray: a native INTEGER[] on Postgres and a JSON array of numbers on SQLite and MySQL, with the symbol-to-integer mapping inlined as when expressions. The column type goes in its own MetaIntEnumArrayColumnType.kt support file, written only into a package that has such a column. The roundtrip-int-enum-array scenario runs in the Kotlin lane, the compile gates no longer leave out the IntEnumArray tier, and the docs and known-gaps entry say what is left (string-backed enum arrays).
mvn metaobjects:init writes the port-neutral .metaobjects/config.json and an empty loadable metaobjects/meta.app.json, each only when missing, and prints the plugin entry to add to the pom with an empty generators list. -Dmeta.init.withDocs=true is the opt-in that adds the api reference generator to the printed entry. It never edits the pom.
@dmealing
dmealing merged commit 921a0a5 into main Nov 21, 2026
10 checks passed
@dmealing
dmealing deleted the fm/mo-130-lane-jvm-bundle2 branch November 21, 2026 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant